<?php

namespace common\models;

use Yii;

/**
 * This is the model class for table "job_record".
 *
 * @property int $id
 * @property int $uid 用户
 * @property int $jid 工作
 * @property string $description 备注
 * @property int $status 状态
 *
 * @property Job $j
 * @property User $u
 */
class JobRecord extends \yii\db\ActiveRecord
{

    const STATUS_SIGN_UP = 10;
    const STATUS_FINESSES = 20;
    const STATUS_CANCEL = 0;
    const STATUS_NOT_PAY = 30;
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return 'job_record';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['uid', 'jid'], 'required'],
            [['uid', 'jid', 'status'], 'integer'],
            [['description'], 'string', 'max' => 255],
            [['jid'], 'exist', 'skipOnError' => true, 'targetClass' => Job::className(), 'targetAttribute' => ['jid' => 'id']],
            [['uid'], 'exist', 'skipOnError' => true, 'targetClass' => User::className(), 'targetAttribute' => ['uid' => 'id']],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'uid' => '用户',
            'jid' => '工作',
            'description' => '备注',
            'status' => '状态',
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getJ()
    {
        return $this->hasOne(Job::className(), ['id' => 'jid']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getU()
    {
        return $this->hasOne(User::className(), ['id' => 'uid']);
    }
}
